package tech.jabari.user.controller;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import tech.jabari.constants.UMSConstant;
import tech.jabari.utils.JdbcUtil;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;
import java.io.IOException;
import java.util.List;

import static tech.jabari.constants.UMSConstant.WELCOME_URL_KEY;

/**
 * 用户退出
 * @author Jabari Lu
 * @title: UserLogoutController
 * @data 2020/8/27 15:01
 */
@Controller
public class UserLogoutController {


    @GetMapping("/logout.action")
    protected String logout(HttpSession session)  {
        // 移除session中的key
        session.removeAttribute(WELCOME_URL_KEY);
        //使session失效
        session.invalidate();
        // 重定向到首页
        return "redirect:/";
    }
}
